
var url=require("url");//引入url模块
//url.parse();解析url 这个最重要
//url.format()合成url
//url.resolve()替换目录
var result=url.parse("http://www.baidu.com?name=zhangsan");
// console.log(result);
var result1=url.format(
    {
        protocol: 'http:',
        slashes: true,
        auth: null,
        host: 'www.baidu.com',
        port: null,
        hostname: 'www.baidu.com',
        hash: null,
        search: '?name=lisi',
        query: 'name=lisi',
        pathname: '/',
        path: '/?name=lisi',
        href: 'http://www.baidu.com/?name=lisi'
    }

);
// console.log(result1);
var result3=url.resolve("http://www.baidu.com/one","news");
console.log(result3);//http://www.baidu.com/news

